//用于演示open函数中参数int flags的原理
//实际上就是通过位图实现不同的标志位对应不同的行为


#include<stdio.h>


//分别对应不同的二进制位
#define ONE 0x1
#define TWO 0x2
#define THREE 0x4
#define FOUR 0x8
#define FIVE 0x10

void Print(int flags)
{
  if(flags & ONE) printf("this is 1\n");//不同标志位对应不同的行为
  if(flags & TWO) printf("this is 2\n");
  if(flags & THREE) printf("this is 3\n");
  if(flags & FOUR) printf("this is 4\n");
  if(flags & FIVE) printf("this is 5\n");
}


int main()
{
  printf("---------------------\n");
  Print(ONE);
  printf("---------------------\n");

  Print(TWO);


  printf("---------------------\n");
  Print(ONE | TWO);

  printf("---------------------\n");
  Print(ONE | TWO|FOUR);


  printf("---------------------\n");
  Print(ONE | TWO | THREE |FOUR|FIVE);
}
